<?php $this->pageTitle = 'Payment Vouchers'; ?>
<?php Yii::app()->clientScript->registerScriptFile('/js/jquery.cookie/jquery.cookie.js'); ?>

<div class="flat_area">
	<div class="main-title no-border clearfix">
		<h1 class="float-left">Payment Vouchers</h1>
		<div class="controls">
			<a id="addPaymentVoucher" class="link-button with-icon" href="<?php echo $this->createUrl('paymentVoucher/giroExport'); ?>">
				<img src="/images/icons/fugue/receipt-export.png" />
				GIRO Export
			</a>
		</div>
	</div>
	<div class="grid_16 relative">
		<div class="search-form">
			<?php
			$this->renderPartial('_search', array(
				'paymentVoucher' => $paymentVoucher,
			));
			?>
		</div><!-- search-form -->
		<?php
		$form = $this->beginWidget('GxActiveForm', array(
			'id' => 'bulk-action-form',
			'action' => array('paymentVoucher/bulkActions'),
		));
		?>
		<div id="ps-payment-voucher-index">
			<?php
			$this->widget('PsGridView', array(
				'id' => 'payment-voucher-index-grid',
				'dataProvider' => $dataProvider,
				'template' => '{pager}{items}{pager}{pagesize}',
				'emptyText' => $emptyText,
				'htmlOptions' => array(
					'class' => 'grid-view grey'
				),
				'pagerCssClass' => 'pager',
				'pagesizeCssClass' => 'pager-pagesize float-right',
				'rowCssClassExpression' => '($data->deleted == 1 ? "deleted" : "")',
				'columns' => array(
					'id' => array(
						'class' => 'CCheckBoxColumn',
						'name' => 'id',
						'value' => '$data->id',
						'selectableRows' => 2,
						'checkBoxHtmlOptions' => array(
							'name' => 'payment_voucher_id[]'
						),
						'htmlOptions' => array(
							'width' => 16,
						),
					),
					array(
						'header' => 'PV Date',
						'type' => 'raw',
						'name' => 'payment_date',
						'value' => 'Yii::app()->dateFormatter->formatDateTime(strtotime($data->payment_date), "short", null)',
						'htmlOptions' => array(
							'width' => 80,
							'class' => 'valign-top'
						)
					),
					array(
						'header' => 'PV #',
						'name' => 'payment_number',
						'type' => 'raw',
						'value' => 'CHtml::link("#" . $data->payment_number, array("paymentVoucher/view", "id" => $data->id), array("class" => "blue link"))',
						'htmlOptions' => array(
							'width' => 120,
							'class' => 'valign-top'
						)
					),
					array(
						'class' => 'common.widgets.grid.PsPartialViewColumn',
						'header' => 'Related Transactions Address',
						'view' => '_transaction_address_column',
						'htmlOptions' => array(
							'width' => '*',
							'class' => 'valign-top'
						)
					),
					array(
						'class' => 'common.widgets.grid.PsPartialViewColumn',
						'header' => 'Related Receipt ',
						'view' => '_receipt_number_column',
						'htmlOptions' => array(
							'width' => '*',
							'class' => 'valign-top'
						)
					),
					array(
						'header' => 'Pay To',
						'name' => 'name',
						'type' => 'raw',
						'value' => '$data->payee_name',
						'htmlOptions' => array(
							'width' => 170,
							'class' => 'valign-top'
						)
					),
					array(
						'header' => 'Payment Method',
						'name' => 'payment_method_type_code',
						'value' => '$data->getPaymentMethod()',
						'htmlOptions' => array(
							'width' => 100,
							'class' => 'valign-top'
						)
					),
					array(
						'name' => 'payment_ref_no',
						'htmlOptions' => array(
							'width' => 120,
							'class' => 'valign-top'
						)
					),
					array(
						'header' => 'Amount',
						'type' => 'raw',
						'value' => 'Yii::app()->numberFormatter->formatCurrency($data->getPaymentVoucherTotal(), "$")',
						'htmlOptions' => array(
							'width' => 80,
							'class' => 'valign-top'
						),
					),
					array(
						'header' => 'Collected On',
						'type' => 'raw',
						'value' => '($data->issued_date ? Yii::app()->dateFormatter->formatDateTime(strtotime($data->issued_date), "short", null) : "Not Collected")',
						'htmlOptions' => array(
							'width' => 80,
							'class' => 'valign-top'
						),
						'visible' => Yii::app()->user->model->agency->settings['Commission']['AutosetIssuedDate'] == 0
					),
				),
			));
			?>
		</div>
		<div class="clearfix">
			<?php if (!$showDeleted): ?>
				<a class="float-left blue link" href="<?php echo $this->createUrl('paymentVoucher/index', array('showDeleted' => true, 'view' => $view)); ?>">Show Cancelled</a>
			<?php else: ?>
				<a class="float-left blue link" href="<?php echo $this->createUrl('paymentVoucher/index', array('view' => $view)); ?>">Hide Cancelled</a>
			<?php endif; ?>
		</div>
		<?php if (Yii::app()->user->model->agency->settings['Commission']['AutosetIssuedDate'] == 0): ?>
			<div>
				<div id="bulk-actions-form">
					<label>Bulk Actions:</label>
					<?php
					echo CHtml::dropDownList('bulk_action', '', array(
						'mark_as_collected' => 'Mark as Collected',
						'mark_as_uncollected' => 'Mark as Uncollected',
					));
					?>

					<?php echo GxHtml::submitButton(Yii::t('app', 'Go'), array('class' => 'blue', 'name' => 'bulk_action_confirm')); ?>
				</div>
			</div>
		<?php endif; ?>
		<?php $this->endWidget(); ?>
	</div>
</div>
<script type="text/javascript">
	var welcomePopupEnabled = <?php echo ($welcomePopupEnabled ? "true" : "false"); ?>;
	var showWhatsNew = <?php echo ($showWhatsNew ? "true" : "false"); ?>;
</script>